/*     */ package com.asiainfo.dacp.catalog.controller;
/*     */ 
/*     */ import com.asiainfo.dacp.jdbc.JdbcTemplate;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Calendar;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.Iterator;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.slf4j.Logger;
/*     */ import org.slf4j.LoggerFactory;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.bind.annotation.ResponseBody;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/catalog"})
/*     */ public class ZBSelectController
/*     */ {
/*  28 */   private static Logger LOG = LoggerFactory.getLogger(ZBSelectController.class);
/*     */   
/*     */ 
/*     */ 
/*     */   @ResponseBody
/*     */   @RequestMapping({"/zb/select"})
/*     */   public Map<String, Object> select(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  36 */     String zbcodes = request.getParameter("zbcodes");
/*  37 */     String optime = request.getParameter("optime");
/*     */     
/*  39 */     String[] zbCodeArry = zbcodes.split(",");
/*  40 */     String zbCodes = "'" + zbcodes + "'";
/*  41 */     String codes = zbCodes.replaceAll(",", "','");
/*  42 */     List<String> list = new ArrayList();
/*  43 */     Map<String, Object> returnMap = new HashMap();
/*  44 */     JdbcTemplate jdbcTemplate = new JdbcTemplate();
/*  45 */     List<Map<String, Object>> resultList = new ArrayList();
/*     */     
/*  47 */     String storesql = "select KPI_CODE,KPI_NAME,KPI_SQL,KPI_TYPE from dacp_kpi_def where KPI_CODE IN (" + codes + ")";
/*  48 */     resultList = jdbcTemplate.queryForList(storesql);
/*  49 */     String tempS = "";
/*  50 */     if (resultList.size() > 0) {
/*  51 */       for (localObject = resultList.iterator(); ((Iterator)localObject).hasNext();) { map = (Map)((Iterator)localObject).next();
/*  52 */         itemMap = new HashMap();
/*  53 */         String kpiType = map.get("KPI_TYPE").toString();
/*  54 */         String kpiCode = map.get("KPI_CODE").toString();
/*  55 */         list.add(kpiCode);
/*  56 */         itemMap.put("name", map.get("KPI_NAME").toString());
/*     */         
/*  58 */         String sql = "";
/*  59 */         if ("offline".equals(kpiType))
/*     */         {
/*  61 */           if (optime == null) {
/*  62 */             Calendar c = Calendar.getInstance();
/*  63 */             c.setTime(new Date());
/*  64 */             c.add(5, -1);
/*  65 */             optime = new SimpleDateFormat("yyyyMMdd").format(c.getTime());
/*     */           }
/*  67 */           sql = "select kpi_value from dacp_kpi_value where kpi_code = '" + kpiCode + "' and optime = '" + optime + "'";
/*     */         }
/*     */         else {
/*  70 */           sql = map.get("KPI_SQL").toString();
/*     */         }
/*  72 */         tempS = String.valueOf(jdbcTemplate.queryForList(sql).get(0));
/*  73 */         tempS = tempS.substring(tempS.indexOf("=") + 1, tempS.length() - 1);
/*  74 */         while ((tempS.endsWith(".")) || (tempS.endsWith("0"))) {
/*  75 */           tempS = tempS.substring(0, tempS.length() - 1);
/*     */         }
/*  77 */         itemMap.put("value", tempS);
/*  78 */         returnMap.put(kpiCode, itemMap);
/*     */       }
/*     */     } else {
/*  81 */       localObject = zbCodeArry;map = localObject.length; for (itemMap = 0; itemMap < map; itemMap++) { String zbCode = localObject[itemMap];
/*  82 */         LOG.error("指标编码" + zbCode + "在配置文件中不存在");
/*  83 */         returnMap.put(zbCode, "");
/*     */       }
/*  85 */       return returnMap;
/*     */     }
/*  87 */     Object localObject = zbCodeArry;Map<String, Object> map = localObject.length; for (Map<String, Object> itemMap = 0; itemMap < map; itemMap++) { String zbCode = localObject[itemMap];
/*  88 */       if (!list.contains(zbCode)) {
/*  89 */         LOG.error("指标编码" + zbCode + "在配置文件中不存在");
/*  90 */         returnMap.put(zbCode, "");
/*     */       }
/*     */     }
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 113 */     return returnMap;
/*     */   }
/*     */ }


/* Location:              C:\Users\my\.m2\repository\com\asiainfo\dacp\dacp-dataos\1.0.0\dacp-dataos-1.0.0.jar!\com\asiainfo\dacp\catalog\controller\ZBSelectController.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */